package com.lmh.graphdisease.service.impl;

import com.lmh.graphdisease.entity.DiseaseEntity;
import com.lmh.graphdisease.repository.DepartmentRepository;
import com.lmh.graphdisease.service.DepartmentService;
import com.lmh.graphdisease.utils.MatchEntityCastUtil;
import org.neo4j.driver.internal.value.NodeValue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author lmh
 * @desc
 * @date 2023/3/7
 */
@Service
public class DepartmentServiceImpl implements DepartmentService {

    @Autowired
    DepartmentRepository departmentRepository;


    @Override
    public List<DiseaseEntity> getBelongToDisease(String name,int num) {
        List<NodeValue> getResult = departmentRepository.getBelongToDepartment(name,num);
        List<DiseaseEntity> diseaseEntities = new ArrayList<>();
        for (NodeValue nodeValue:getResult){
            diseaseEntities.add(MatchEntityCastUtil.MatchToDiaseaseEntity(nodeValue));
        }
//        System.out.println(diseaseEntities.size());
//        for (DiseaseEntity diseaseEntity:diseaseEntities){
//            System.out.println(diseaseEntity.getName());
//        }
        return diseaseEntities;
    }
}
